package com.moif.ttakji.game;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyItemView extends LinearLayout{

	TextView titleView;
	TextView descView;
	TextView descView2;
	MyData mData;
	ImageView imageView;
	
	OnItemImageClickListener mListener;
	
	public interface OnItemImageClickListener{
		public void onItemImageClick(MyData data);
	}
	
	public void setOnItemImageClickListener(OnItemImageClickListener listener){
		mListener = listener;
	}
	
	public MyItemView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		LayoutInflater inflater = LayoutInflater.from(context);
		inflater.inflate(R.layout.item_laytout, this);
		titleView = (TextView)findViewById(R.id.textView1);
		descView = (TextView)findViewById(R.id.textView2);
		descView2 = (TextView)findViewById(R.id.textView3);
		imageView = (ImageView)findViewById(R.id.imageView1);
		imageView.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(mListener !=null){
					mListener.onItemImageClick(mData);
				}
			}
		});
		
	}
	
	public void setData(MyData data){
		mData = data;
		
		if(data.what==1){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak1);
			imageView.setImageDrawable(img);
		}else if(data.what==2){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak2);
			imageView.setImageDrawable(img);
		}else if(data.what==3){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak3);
			imageView.setImageDrawable(img);
		}else if(data.what==4){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak4);
			imageView.setImageDrawable(img);
		}else if(data.what==5){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak5);
			imageView.setImageDrawable(img);
		}else if(data.what==6){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak6);
			imageView.setImageDrawable(img);
		}else if(data.what==7){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak7);
			imageView.setImageDrawable(img);
		}else if(data.what==8){
			BitmapDrawable img = (BitmapDrawable)getResources().getDrawable(R.drawable.ndak8);
			imageView.setImageDrawable(img);
		}
			
			
		titleView.setText(data.title);
		descView.setText(data.desc);
		descView2.setText(data.desc2);
	}
}
